#include "DijkstraApp.h"

#include <string>
#include <cstdio>


DijkstraApp::DijkstraApp()
{
}


DijkstraApp::~DijkstraApp()
{
}


HRESULT DijkstraApp::OnCreate()
{
	return Win32Application::OnCreate();
}


void DijkstraApp::OnRelease()
{
}


bool DijkstraApp::OnMessage(UINT msg, WPARAM wparam, LPARAM lparam)
{
	return Win32Application::OnMessage(msg, wparam, lparam);
}


void DijkstraApp::OnMouseDown(DWORD button, int x, int y)
{
	m_points.push_back(PointF((float)x, (float)y));
	Refresh();
}


void DijkstraApp::OnMouseUp(DWORD button, int x, int y)
{
}


void DijkstraApp::OnMouseMove(DWORD button, int x, int y)
{
	m_mousePosition = PointF((float)x, (float)y);
	Refresh();
}


void DijkstraApp::OnKeyDown(DWORD key)
{
}


void DijkstraApp::OnChar(char c)
{
}


void DijkstraApp::OnPaint(Graphics& graphics)
{
	::Beep(10000, 1);

	graphics.SetSmoothingMode(SmoothingModeAntiAlias);
	graphics.Clear(Color::White);

	wchar_t s[80];
	swprintf_s(s, L"X: %.0f Y: %.0f\n", (float) m_mousePosition.X, (float) m_mousePosition.Y);

	Font font(_T("Segoe UI"), 10.0);
	SolidBrush brush(Color::Black);

	graphics.DrawString(
		s, wcslen(s),
		&font,
		PointF(10, 10),
		&brush);

	Pen pen(Color::Red);

	for (auto it = m_points.begin(); it != m_points.end(); it++) {
		PointF pt = *it;
		graphics.DrawEllipse(&pen, pt.X - 5.0f, pt.Y - 5.0f, 10.0f, 10.0f);
	}
}
